import { OrderList } from './orderList';
import { ClassifyItems } from './classifyItems';
import { SuspendedOrderItems } from './suspendedOrderItems';
import { SuspendedOrderItem } from './suspendedOrderItem';
import { SuspendedOrders } from './suspendedOrders';
import { SuspendedOrder } from './suspendedOrder';
import { DeliverOrders } from './deliverOrders';
import { routeModel } from './../setup/index';
import { NewHome } from './newHome';
import { GroupedItemsTransform } from "./pipe";

export class NewHomeService {
    static current = new NewHomeService();
    route: routeModel = {
        path: 'newHome/:id', component: NewHome, title: "设置", url: "newHome",//redirectTo
        children: [
        ]
    }
    components = [DeliverOrders, SuspendedOrders, SuspendedOrder, SuspendedOrderItems, SuspendedOrderItem, ClassifyItems, OrderList]
    pipes = [GroupedItemsTransform]
    forRoot() {
        function traverse(data) {
            let arr = [];
            arr.push(data.component);
            for (let key in data) {
                if (Array.isArray(data[key])) {
                    data[key].forEach(v => {
                        arr = arr.concat(traverse(v))
                    })
                }
            }
            return arr;
        }
        let components = traverse(this.route);
        return components.concat(this.components).concat(this.pipes);
    }
}